package ${package.Entity};

<#if table.name=="sys_user" || table.name=="sys_role">
import java.util.List;
</#if>
import com.baomidou.mybatisplus.annotation.TableField;
<#list table.importPackages as pkg>import ${pkg};
</#list>
<#if swagger2>
    import io.swagger.annotations.ApiModel;
    import io.swagger.annotations.ApiModelProperty;
</#if>
<#list table.fields as field>
    <#if field.keyFlag!=true && field.name?contains("_id")>
import ${package.Entity}.${field.capitalName?replace("Id","")};
    </#if>
</#list>
<#if entityLombokModel>
    import lombok.Data;
    import lombok.EqualsAndHashCode;
    import lombok.experimental.Accessors;
</#if>
<#if table.name?contains("_n_") || table.name?contains("_m_")>
    import java.util.List;
</#if>
/**
* <p>
    * ${table.comment!}
    * </p>
*
* @author ${author}
* @since ${date}
*/
<#if entityLombokModel>
    @Data
    <#if superEntityClass??>
        @EqualsAndHashCode(callSuper = true)
    <#else>
        @EqualsAndHashCode(callSuper = false)
    </#if>
    @Accessors(chain = true)
</#if>
<#if table.convert>
    @TableName("${table.name}")
</#if>
<#if swagger2>
    @ApiModel(value="${entity}对象", description="${table.comment!}")
</#if>
<#if superEntityClass??>
    public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> {
<#elseif activeRecord>
    public class ${entity} extends Model<${entity}> {
<#elseif table.name?contains("_n_") || table.name?contains("_m_")>
    public class ${entity} extends  ${table.fields[1].capitalName?replace("Id","")}{
<#else >
    public class ${entity} implements Serializable {
</#if>
private static final long serialVersionUID = 1L;
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#if !table.name?contains("_n_")&&!table.name?contains("_m_")>
<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>
    <#if field.comment!?length gt 0>
        <#if swagger2>
            @ApiModelProperty(value = "${field.comment}")
        <#else>
            /**
            * ${field.comment}
            */
        </#if>
    </#if>
    <#if field.keyFlag>
    <#-- 主键 -->
        <#if field.keyIdentityFlag>
            @TableId(value = "${field.name}", type = IdType.AUTO)
        <#elseif idType??>
            @TableId(value = "${field.name}", type = IdType.${idType})
        <#elseif field.convert>
            @TableId("${field.name}")
        </#if>
    <#-- 普通字段 -->
    <#elseif field.fill??>
    <#-- -----   存在字段填充设置   ----->
        <#if field.convert>
            @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
        <#else>
            @TableField(fill = FieldFill.${field.fill})
        </#if>
    <#elseif field.convert>
        @TableField("${field.name}")
    </#if>
<#-- 乐观锁注解 -->
    <#if (versionFieldName!"") == field.name>
        @Version
    </#if>
<#-- 逻辑删除注解 -->
    <#if (logicDeleteFieldName!"") == field.name>
        @TableLogic
    </#if>
    private ${field.propertyType} ${field.propertyName};
<#--关联表字段-->
    <#if field.keyFlag!=true && field.name?contains("_id")>
        /**
        *${field.comment}关联属性
        */
        @TableField(exist = false)
        private ${field.capitalName?replace("Id","")} ${field.propertyName?replace("Id","")};
    </#if>
</#list>
<#------------  END 字段循环遍历  ---------->
<#else >
    <#--关联表生成字段-->
<#if table.fields[0].keyFlag>
<#-- 主键 -->
    <#if table.fields[0].keyIdentityFlag>
        @TableId(value = "${table.fields[0].name}", type = IdType.AUTO)
    <#elseif idType??>
        @TableId(value = "${table.fields[0].name}", type = IdType.${idType})
    <#elseif table.fields[0].convert>
        @TableId("${table.fields[0].name}")
    </#if>
    private ${table.fields[0].propertyType} ${table.fields[0].propertyName};
    /**
     * ${table.fields[2].comment!}属性
     */
    @TableField(exist = false)
    private List<${table.fields[2].capitalName?replace("Id","")}> ${table.fields[2].propertyName?replace("Id","")}s;
</#if>
</#if>
<#if !entityLombokModel>
    <#list table.fields as field>
        <#if field.propertyType == "boolean">
            <#assign getprefix="is"/>
        <#else>
            <#assign getprefix="get"/>
        </#if>
        public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
        }

        <#if entityBuilderModel>
            public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        <#else>
            public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        </#if>
        this.${field.propertyName} = ${field.propertyName};
        <#if entityBuilderModel>
            return this;
        </#if>
        }
    </#list>
</#if>

<#if entityColumnConstant>
    <#list table.fields as field>
        public static final String ${field.name?upper_case} = "${field.name}";

    </#list>
</#if>
<#if activeRecord>
    @Override
    protected Serializable pkVal() {
    <#if keyPropertyName??>
        return this.${keyPropertyName};
    <#else>
        return null;
    </#if>
    }

</#if>
<#if !entityLombokModel>
    @Override
    public String toString() {
    return "${entity}{" +
    <#list table.fields as field>
        <#if field_index==0>
            "${field.propertyName}=" + ${field.propertyName} +
        <#else>
            ", ${field.propertyName}=" + ${field.propertyName} +
        </#if>
    </#list>
    "}";
    }
</#if>
<#if table.name=="sys_user">
@TableField(exist = false)
@ApiModelProperty(hidden = true)
private List<SysRole> sysRoles;
    @TableField(exist = false)
    @ApiModelProperty(hidden = true)
    private String token;
</#if>
    <#if table.name=="sys_role">
    @TableField(exist = false)
    @ApiModelProperty(hidden = true)
    private List<SysMenu> sysMenus;
        </#if>
}
